package com.yjq0714.test1;

import java.util.ArrayList;

public class SpearateString {
    public static ArrayList<String> speOne(String string) {
        int j = 0;
        ArrayList<String> arrayList = new ArrayList<>();
        for (int i = 0; i < string.length(); i++) {
            if ((string.charAt(i) == '/')) {
                if ((string.charAt(i-1) != '/')){
                arrayList.add(string.substring(j, i));}
                j = i + 1;
            } else if (i == string.length() - 1) {
                arrayList.add(string.substring(j, i + 1));
            }
        }
        return arrayList;
    }

    public static ArrayList<String> speTwo(String string) {
        String[] s = string.split("/");
        ArrayList<String> arrayList = new ArrayList<>();
        for (String ss:s
             ) {
            if (!(ss.equals(""))){
                arrayList.add(ss);
            }
        }
        return arrayList;
    }
}
